﻿using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.ViewModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using CWM.Client.Utils;

namespace CWM.Client.ViewModels
{
    public partial class IndexPageViewModel : NotificationObject
    {

        // 命令声明
        public DelegateCommand QueryCommand { get; private set; }
        public DelegateCommand SelectClientCommand { get; private set; }
        public DelegateCommand<Object> CallCommand3 { get; private set; }

        public IndexPageViewModel ()
        {
            QueryCommand = new DelegateCommand(Query);
            //..
        }


    private string _serviceProvider;

        public string ServiceProvider
        {
            get { return _serviceProvider; }
            set
            {
                _serviceProvider = value;
                this.RaisePropertyChanged("ServiceProvider");
            }
        }

        private string _expressModel;

        public string ExpressModel
        {
            get { return _expressModel; }
            set
            {
                _expressModel = value;
                this.RaisePropertyChanged("ExpressModel");
            }
        }


        private DataTable _dataTable;

        public DataTable DataTable
        {
            get { return _dataTable; }
            set
            {
                _dataTable = value;
                this.RaisePropertyChanged("DataTable");
            }
        }


        public void Query()
        {
            try
            {
                this.DataTable = DataRequest.Query("Select t.client_id,t.waybill_num,t.transfer_num,t.create_date,t.weight,t.status from t_order t");
                MessageBox.Show("查询结果 列数：" + this.DataTable.Columns.Count.ToString() + "\t行数：" + this.DataTable.Rows.Count.ToString());
            }
            catch(Exception e)
            {
                MessageBox.Show(e.Message);
            }
            
        }

        /*
        public void SelectClient()
        {
            try
            {
                new ClientSelectWindow().ShowDialog();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
        */

    }
}
